package 函数式接口;

import java.util.function.Consumer;
import java.util.function.Supplier;

@FunctionalInterface
interface IGame{
    public void run();
}

class Stu{
    public void play(IGame game){
        game.run();
    }
}

class Tea{
    public void reading(){
        System.out.println("老师喜欢读书");
    }
}
public class Demo3 {

    public static void main(String[] args) {
//        Stu stu = new Stu();
//        stu.play(()->{
//            System.out.println("我喜欢篮球");
//        });
//
//        Tea tea = new Tea();
//        stu.play(tea::reading);
//        stu.play(new Tea()::reading);

//        setSpl(()->{return "Hello";});
//        setSplInteger(()-> {return 10;});

        f1((s)-> System.out.println(s),"Hello");
        f2((n)-> System.out.println(n),10);
    }

    public static void setSpl(Supplier<String> spl) {
        System.out.println(spl.get());
    }

    public static void setSplInteger(Supplier<Integer> intSpl) {
        System.out.println("一个int值：" + intSpl.get());
    }

    public static void  f1(Consumer<String> c,String str){
        c.accept(str);

    }

    public static void f2(Consumer<Integer> c, Integer integer) {
        c.accept(integer);
    }
}
